package jk.fox.transport;

import jk.fox.common.payload.request.Request;
import jk.fox.common.payload.response.Response;
import jk.fox.exchange.ExchangeChannel;

import java.net.SocketAddress;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.SynchronousQueue;

/**
 * @author cuichao
 * @param <T>
 */
public interface ClientTransporter<T extends ExchangeChannel> {

    ConcurrentMap<String ,SynchronousQueue<Response>> selector = new ConcurrentHashMap<>();
    /**
     * 发送Rpc消息
     * @param t
     * @param request
     * @param timeout
     * @return
     * @throws Exception
     */
    Response send(T t,Request request,long timeout) throws Exception;
    /**
     * 连接远程服务器
     * @param address
     * @return
     * @throws Exception
     */
    T doConnection(SocketAddress address) throws Exception;

}
